slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.87k stars 3.41k forks source link

embedded videos cannot be exported in html #4186

Open raimotheculturefactor opened 6 months ago

raimotheculturefactor commented 6 months ago

I'm adding an embedded video in the editor. The editor shows the video in an iframe. My problem is when I want to get the html content from the editor. It returns a link, not the iframe as whole.

Steps for Reproduction

  1. open the editor
  2. add a video
  3. get the html from editor

Expected behavior:

expecting the return value be:

Actual behavior:

<a href="${video}">${video}</a> is returned

Platforms:

windows

Version:

2.0.*

winterlimelight commented 2 weeks ago

I worked around this by removing the html() method from the video format. video.js has a function called html() which returns <a href="${video}">${video}</a> and is called by editor.js convertHTML(). By overriding the video format with a class with html() undefined, the HTML generation reverted back to the old behaviour of creating an iframe.

This is from an Angular using ngx-quill and written in TypeScript, but I assume doing something similar following the customization docs will work in plain JS:


import QuillVideo from 'quill/formats/video'

// Eliminate the html method so that convertHTML does not turn the iframe into a anchor tag
// which it then fails to convert back to an iframe when it loads.
export class MyQuillVideo extends QuillVideo {
    html = null; 
}

// and in my ngx-quill options:
customModules: [
    { path: 'formats/video', implementation: MyQuillVideo }
]