How to filter out element with its content in CKE5 data

41 views Asked by At

Let's imagine there is initial data for CKEditor 5 such as:

const data = `<style type="text/css" style="display:none">
                <!-- .foo { color: red} -->
              </style>
              <div>test</div>`;

I aim to get just <div>test</div> as output of CKEditor5. GHS plugin is not used, so, all unsupported elements are stripped out according to the set of included features to my build. In my case, <style> is out, that's fine.

Output of CKE5:

'<p>&lt;!-- .foo { color: red} --&gt;&nbsp;</p><p>test</p>'

Basically, from what I see, it just replaces unsupported <style> HTML element with <p> element. However, I wish to completely remove it with all content. We might need to leverage some kind of data pipeline API...

Hence, how to filter out <style> element with its internal content before CKE5 pass incoming data through conversions and its model?

0

There are 0 answers