|
@@ -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 => '...'
|
|
|
* },
|
|
* },
|
|
|
* ...
|
|
* ...
|