Changeset 1907a18 in Klonkt for src/services/AudioEmbedService.js


Ignore:
Timestamp:
06/15/2026 01:48:56 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d352b63
Parents:
851239c
Message:

feat: embed media via editor button ([[embed:url]] shortcode)

Embed YouTube/Spotify/SoundCloud/Vimeo/Apple Music/Bandcamp with a toolbar
button in the post editor: paste a URL -> [[embed:url]] chip -> server renders
an iframe (AudioEmbedService.embedMediaShortcodes, in the existing embed pipeline).
Standalone URL lines also embed via autoembed(). CSP already allows the domains.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/AudioEmbedService.js

    r851239c r1907a18  
    187187      }
    188188    );
     189  }
     190
     191  /**
     192   * Replace [[embed:<url>]] shortcodes met de platform-iframe (YouTube, Spotify,
     193   * SoundCloud, Apple Music, Bandcamp, Vimeo). De editor-knop voegt deze
     194   * shortcode in; losse URL-regels embedden ook automatisch via autoembed().
     195   * Niet-ondersteunde/ongeldige URLs krijgen een nette inline-melding.
     196   */
     197  static embedMediaShortcodes(html) {
     198    if (!html) return html;
     199    return html.replace(/\[\[embed:([^\]]+)\]\]/gi, (match, rawUrl) => {
     200      const url = rawUrl.trim().replace(/&amp;/g, '&');
     201      const detected = this.detectProvider(url);
     202      if (!detected) {
     203        return `<div class="post-embed-missing"><em>Embed: niet-ondersteunde of ongeldige URL.</em></div>`;
     204      }
     205      return this.generateIframe(detected.provider, detected) || match;
     206    });
    189207  }
    190208
Note: See TracChangeset for help on using the changeset viewer.