0

I have a self-contained widget written by a third party that consists of HTML, JS, and CSS. I've dumped it into a custom block with Full HTML (and verified the Full HTML settings are loose enough that they shouldn't conflict with the markup). Also, I'm using CKEditor. When I save the custom block, it turns <div class="bookwidget"> into <div class="bookwidget">&nbsp;</div> so that the widget doesn't even get an opportunity to render.

Is there a workaround for this? Is my only alternative to create a custom module?

2 Answers 2

0

Try going to Admin menu > Configuration > Content authoring > Text formats and editors then edit yours (E.g. "basic html")

Down towards the bottom you should see an option: Correct faulty and chopped off HTML - uncheck that option and save.

Not sure why a widget would expect an un-closed <div /> tag though.

1
  • That option is unchecked. There is a close div, it's just after all the HTML/JS/CSS. But when the editor rewrites it, it removes the </div> at the end and sticks it at the top.
    – Chanel
    Commented Dec 8, 2020 at 21:48
0

If you want to avoid creating a custom plugin, then I would try creating a new Text Format and remove all processing options and offer no WYSIWYG.

However, this block of code sounds problematic, and the WYSIWYG is not really intended to host full applications. I think you would end up with a more reliable, more secure, higher quality product if you created a custom block and integrated the JS and CSS as libraries. This is more in line with the way that Drupal is intended to operate and allows the markup and JS/CSS assets to properly participate in sanitization, caching, aggregation, etc...

1
  • I did try creating a custom text format which had no editor and didn't do anything to the HTML. The result wouldn't render the HTML. I'll look into creating a custom block. I just thought this could be so easy.
    – Chanel
    Commented Dec 9, 2020 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.