Browse Source

Docs: Updated docs after the configuration has been simplified.

Aleksander Nowodzinski 7 years ago
parent
commit
31f53ba7f6

+ 2 - 2
packages/ckeditor5-media-embed/docs/features/media-embed.md

@@ -148,7 +148,7 @@ ClassicEditor
 			providers: [
 			providers: [
 				{
 				{
 					// An URL regexp or array of URL regexps:
 					// An URL regexp or array of URL regexps:
-					url: /^(https:\/\/)?(www\.)?example\.com\/media\/(\w+)/,
+					url: /^example\.com\/media\/(\w+)/,
 
 
 					// To be defined only if the media is previewable:
 					// To be defined only if the media is previewable:
 					html: mediaId => '...'
 					html: mediaId => '...'
@@ -365,7 +365,7 @@ mediaEmbed: {
 	extraProviders: [
 	extraProviders: [
 		{
 		{
 			name: 'ckeditor',
 			name: 'ckeditor',
-			url: /^(https:\/\/)?(www\.)?ckeditor\.com/
+			url: /^ckeditor\.com/
 		}
 		}
 	]
 	]
 }
 }

+ 14 - 8
packages/ckeditor5-media-embed/src/mediaembed.js

@@ -49,9 +49,12 @@ export default class MediaEmbed extends Plugin {
  *		{
  *		{
  *			name: 'example',
  *			name: 'example',
  *
  *
- *			// The following RegExp matches https://www.example.com/media/{media id}
- *			// with optional "https://" and "www" prefixes.
- *			url: /^(https:\/\/)?(www\.)?example\.com\/media\/(\w+)/,
+ *			// The following RegExp matches https://www.example.com/media/{media id},
+ *			// (either with "https://" and "www" or without), so the valid URLs are:
+ *			// * https://www.example.com/media/{media id}
+ *			// * www.example.com/media/{media id}
+ *			// * example.com/media/{media id}
+ *			url: /^example\.com\/media\/(\w+)/,
  *
  *
  *			// The rendering function of the provider.
  *			// The rendering function of the provider.
  *			// Used to represent the media when editing the content (i.e. in the view)
  *			// Used to represent the media when editing the content (i.e. in the view)
@@ -65,7 +68,7 @@ export default class MediaEmbed extends Plugin {
  *
  *
  *		{
  *		{
  *			name: 'allow-all',
  *			name: 'allow-all',
- *			url: /^(https:\/\/)?(www\.)?.+/
+ *			url: /^.+/
  *		}
  *		}
  *
  *
  * To implement a responsive media, you can use the following HTML structure:
  * To implement a responsive media, you can use the following HTML structure:
@@ -84,8 +87,11 @@ export default class MediaEmbed extends Plugin {
  * @property {String} name The name of the provider. Used e.g. when
  * @property {String} name The name of the provider. Used e.g. when
  * {@link module:media-embed/mediaembed~MediaEmbedConfig#removeProviders removing providers}.
  * {@link module:media-embed/mediaembed~MediaEmbedConfig#removeProviders removing providers}.
  * @property {RegExp|Array.<RegExp>} url The `RegExp` object (or array of objects) defining the URL of the media.
  * @property {RegExp|Array.<RegExp>} url The `RegExp` object (or array of objects) defining the URL of the media.
- * If any URL matches the `RegExp`, it becomes the media in editor model, as defined by the provider. The content
- * of the last matching group is passed to the `html` rendering function of the media.
+ * If any URL matches the `RegExp`, it becomes the media in editor model, as defined by the provider. The result
+ * of matching (output of `String.prototype.match()`) is passed to the `html` rendering function of the media.
+ *
+ * **Note:** You do not need to include the protocol (`https://`) and `www` sub–domain in your `RegExps`, they are
+ * stripped from the URLs before matching anyway.
  * @property {Function} [html] (optional) Rendering function of the media. The function receives the entire matching
  * @property {Function} [html] (optional) Rendering function of the media. The function receives the entire matching
  * array from the corresponding `url` `RegExp` as an argument, allowing rendering a dedicated
  * array from the corresponding `url` `RegExp` as an argument, allowing rendering a dedicated
  * preview of a media identified by a certain id or a hash. When not defined, the media embed feature
  * preview of a media identified by a certain id or a hash. When not defined, the media embed feature
@@ -161,7 +167,7 @@ export default class MediaEmbed extends Plugin {
  *					providers: [
  *					providers: [
  *						{
  *						{
  *							 name: 'myProvider',
  *							 name: 'myProvider',
- *							 url: /^(https:\/\/)?(www\.)?example\.com\/media\/(\w+)/,
+ *							 url: /^example\.com\/media\/(\w+)/,
  *							 html: match => '...'
  *							 html: match => '...'
  *						},
  *						},
  *						...
  *						...
@@ -191,7 +197,7 @@ export default class MediaEmbed extends Plugin {
  *					extraProviders: [
  *					extraProviders: [
  *						{
  *						{
  *							 name: 'extraProvider',
  *							 name: 'extraProvider',
- *							 url: /^(https:\/\/)?(www\.)?example\.com\/media\/(\w+)/,
+ *							 url: /^example\.com\/media\/(\w+)/,
  *							 html: match => '...'
  *							 html: match => '...'
  *						},
  *						},
  *						...
  *						...