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

Using custom block blot wraps Line Breaks #4599

Open
KayleighWhitehurst opened this issue Feb 10, 2025 · 1 comment
Open

Using custom block blot wraps Line Breaks #4599

KayleighWhitehurst opened this issue Feb 10, 2025 · 1 comment

Comments

@KayleighWhitehurst
Copy link

I am trying to overwrite the basic block function of the editor so that all of the elements created by the user are created as styled spans.

i am overwriting the block blot with the following:

        // Custom Paragraph Blot (Replaces <p>)
        class CustomParagraph extends Block {
            static create() {
                let node = super.create();
                node.setAttribute('data-type', 'p'); // Replace <p> with <span data-type="p">
                return node;
            }
        }
        CustomParagraph.blotName = 'block';
        CustomParagraph.tagName = 'span'; // Use <span> instead of <p>
        Quill.register(CustomParagraph, true); // Overwrite default

but when I type and press return, instead of wrapping the text node in the span and adding the break element onto the end, it also wraps the break element in a span.

<span data-type="p">sdfasd</span><span data-type="p"><br></span>

Should this be the case, or is there a better way to do this?

@KayleighWhitehurst
Copy link
Author

Codepen is here: https://codepen.io/kayrah87/pen/raNBrQw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant