editorjs-html icon indicating copy to clipboard operation
editorjs-html copied to clipboard

Unable to save most embed types

Open mendhak opened this issue 1 year ago • 1 comments

Hi hope I can explain this well.

When trying to use the Embed Tool, most embed types get blocked in editorjs-html by default with this error message:

Saving failed: Error: Only Youtube and Vime Embeds are supported right now.

I tried looking at the PR that introduced this but I couldn't figure out why it was being blocked.

Is there a way to allow other embeds through "as-is" as raw HTML? So this way we can create our custom embeds and just have it saved. There are probably thousands of different sites that provide embeds so it would be impractical to have a specific code for each one, that's why I'm wondering about a fallback 'raw HTML' approach?

Thanks

mendhak avatar May 01 '24 12:05 mendhak

OK I think a workaround could be, define a custom parser (which editorjs-html) allows, and have it just

function embedParser(block){
                        return `<iframe src="${block.data.embed}" scrolling="no" frameborder="0" style="border: none;" width="600" height="557" data-external="1"></iframe>`
                        
                    }

And then give it to the parser when you initialise it

const edjsParser = edjsHTML({ embed: embedParser, });

mendhak avatar May 01 '24 13:05 mendhak