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

Problems can arise when the embed element is built #4182

Open
muzhiLL opened this issue May 7, 2024 · 0 comments
Open

Problems can arise when the embed element is built #4182

muzhiLL opened this issue May 7, 2024 · 0 comments

Comments

@muzhiLL
Copy link

muzhiLL commented May 7, 2024

It's an honor to use your team's rich text editor.

One of the problems I encountered was that when I used html directly to manipulate content in rich text, if it included embed elements such as images, the re-rendered page would have some empty lines before and after these embed elements.

I looked at your source code below:

Snipaste_2024-05-07_13-19-54

It turns out that when you construct embed content, you automatically add empty lines to and from the embed element, whereas when I manipulate rich text content, because I'm working directly with html, the content includes the existing empty lines. If I re-assign html to a rich text editor, it adds extra blank lines, which causes me this problem.

So I was wondering, before you create the embed element, if you can add an element with an empty line, if you already have an empty line, then you don't add any more, in order to be compatible with the problem of reading content directly through html.

The changes I made myself are as follows.

constructor(scroll, node) {
        super(scroll, node);
        if (this.domNode.childNodes[0].data === document.createTextNode(GUARD_TEXT).data) {
            return;
        }
        this.contentNode = document.createElement('span');
        this.contentNode.setAttribute('contenteditable\', false);
        Array.from(this.domNode.childNodes).forEach(childNode => {
            this.contentNode.appendChild(childNode);
        });
        this.leftGuard = document.createTextNode(GUARD_TEXT);
        this.rightGuard = document.createTextNode(GUARD_TEXT);
        this.domNode.appendChild(this.leftGuard);
        this.domNode.appendChild(this.contentNode);
        this.domNode.appendChild(this.rightGuard);
    }

Hope to get your reply, thank you very much.

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