wontlost-ltd / vaadin-litelement-ckeditor

Vaadin14+LitElement+CKEditor5
Other
17 stars 13 forks source link

Question: Do you have a working example of Config.setMediaEmbed with youtube provider #54

Open johnfilo-kmart opened 1 year ago

johnfilo-kmart commented 1 year ago

Hello,

I am trying to use setMediaEmbed in Config and add youtube as a provider, but I can't seem to find any documentation on how to do this.

Looking at the documentation of CKEditor MediaEmbedProvider, it shows a block of JSON is needed. However, the setMediaEmbed method takes List<String> for providers.

Here is what I am trying

Config config = new Config();
List<String> providers = new ArrayList<String>();
String youtubeProvider = "{ name: 'extraProvider', url: /^www.youtube\\.com/(\\w+)/, html: match => '...'}";
providers.add(youtubeProvider);
List<String> empty = new ArrayList<String>();
config.setMediaEmbed(true, providers, empty, empty, empty);

Any help would be so appreciated!

johnfilo-kmart commented 1 year ago

Also, the documentation from CKEditor shows this as a valid configuration:

editorConfig = {
    mediaEmbed: {
        previewsInData: true
    }
}

However, when I tried to set all the other options of setMediaEmbed to empty lists, it still says that the URL is not a valid provider in the editor UI.

Config config = new Config();
List<String> empty = new ArrayList<String>();
config.setMediaEmbed(true, empty, empty, empty, empty);

So, is it possible to ONLY set previewsInData: true through Config setMediaEmbed ?