Skip to content

Adding dynamic HTML content to ContentEdit Element #23

@Filip785

Description

@Filip785

Hello,

Is it possible that if I add some dynamic HTML like this:

<div class="block">
    <h1 id="headingText">Heading Text</h1>
    <p id="subheadingText">Subheading text</p>
</div>

to the ContentEdit element (like ContentEdit.Text) to prevent removing elements from the DOM when all of the text is removed from them.
Ideally, what I am trying to do is that if you remove the text from h1 tag for example, the caret would stay at the index 0 and if you press the backspace again nothing would happen.

The second question I have is if it is possible to, again, add dynamic HTML to the ContentEdit element and keep the empty tags. For example if I add HTML like this:

<div class="block">
    <h1>Heading text</h1>
    <!-- Gets removed by HTMLString -->
    <div class="emptyBlock"></div>
</div>

Div element with the class of emptyBlock would be removed from the DOM.
I have debugged this little bit and discovered that _Parser.prototype._popTag function of html-string.js removes them, but I am unable to prevent it.
Is there any solution to this?
I know that by adding &nbsp; to the empty element would prevent it from being removed from the DOM but this doesn't work for me in every case since in some elements I need to add HTML that looks like this:

<svg width="..." height="...">
    <!-- This element again gets removed from the DOM -->
    <path d="..." />
</svg>

Any help would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions