Browse Source

DOC-2301: Refactor media_url_resolver function to use a Promise for better control flow (#3112)

pull/3123/head
Arvin(Jintao) Han 1 year ago
committed by GitHub
parent
commit
4522efac06
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 16
      modules/ROOT/partials/configuration/media_url_resolver.adoc

16
modules/ROOT/partials/configuration/media_url_resolver.adoc

@ -21,13 +21,15 @@ tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'media',
toolbar: 'media',
media_url_resolver: (data, resolve/*, reject*/) => {
if (data.url.indexOf('YOUR_SPECIAL_VIDEO_URL') !== -1) {
const embedHtml = `<iframe src="${data.url}" width="400" height="400" ></iframe>`;
resolve({ html: embedHtml });
} else {
resolve({ html: '' });
}
media_url_resolver: (data) => {
return new Promise((resolve) => {
if (data.url.indexOf('YOUR_SPECIAL_VIDEO_URL') !== -1) {
const embedHtml = `<iframe src="${data.url}" width="400" height="400" ></iframe>`;
resolve({ html: embedHtml });
} else {
resolve({ html: '' });
}
});
}
});
----
Loading…
Cancel
Save