embed
embed copied to clipboard
Async id function?
I know now it is not an option but imagine this use case. If you paste shorten link to sketchfab (for example https://skfb.ly/oDtnZ) you need to make request to this url and follow redirects to find real id to be inserted in iframe. So the id function would be like this:
As an option:
class AsyncIDEmbed extends Embed {
async onPaste(event) {
const { key: service, data: url } = event.detail;
const { regex, embedUrl, width, height, id = async (ids) => ids.shift() } = Embed.services[service];
const result = regex.exec(url).slice(1);
const embed = embedUrl.replace(/<%= remote_id %>/g, await id(result));
this.data = {
service,
source: url,
embed,
width,
height,
};
}
}