Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert Html 5 video tag #2212

Open
AaricChenLegacy opened this issue Aug 2, 2018 · 2 comments
Open

Insert Html 5 video tag #2212

AaricChenLegacy opened this issue Aug 2, 2018 · 2 comments
Labels
documentation Issues common enough that documentation/examples are needed

Comments

@AaricChenLegacy
Copy link

AaricChenLegacy commented Aug 2, 2018


        toolbar.addHandler('video', function () {
            let url = prompt("Video link");
            if (url) {
                let range = quill.getSelection(true);
                quill.updateContents(new Delta()
                    .retain(range.index)
                    .delete(range.length)
                    .insert(myViedo));
            }
        });

expected out put is


<video width="100%" height="500px" controls>
  <source src="myVideoLink" type="video/mp4">
Your browser does not support the video tag.
</video>

I know currently quill use iframe to insert video. how to do above insert with quill?

please help

@ycjcl868
Copy link

me too, can't insert <audio> tag

@dennismwagiru
Copy link

dennismwagiru commented Sep 27, 2022

me too, can't insert <audio> tag

To provide a constistent editing experience, you need both consistent data and predictable behaviors. The DOM unfortunately lacks both of these. The solution for Quill is to maintain its own document model ie Parchment to represent its content. It is organized in its own codebase with its own API layer.

For the audio and video tags to work, you have to implement Blots for these tags. A Blot is the basic building block of a Parchment document. Several basic implementations such as Block, Inline and Embed are provided.

To create an Audio Blot, we can extend the Embed Blot as follows

import Quill from 'quill';
let BlockEmbed = Quill.import('blots/block/embed');

class AudioBlot extends BlockEmbed {
    static create(value) {
        let node = super.create();
        node.setAttribute('controls', true);
        node.setAttribute('src', value);
        return node;
    }

    static value(node) {
        return {
            src: node.getAttribute('src'),
        };
    }
}

AudioBlot.blotName = 'audio';
AudioBlot.tagName = 'audio';

export default AudioBlot;

Then import and register AudioBlot before using Quill as follows:-

import Quill from 'quill';
import AudioBlot from './AudioBlot';

Quill.register(AudioBlot, true);
export default Quill;

@luin luin added the documentation Issues common enough that documentation/examples are needed label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues common enough that documentation/examples are needed
Projects
None yet
Development

No branches or pull requests

4 participants