Modern Content Editor Web Part

The Modern Content Editor Web Part replicates the classic SharePoint Content Editor Web part and lets you link to a HTML file containing HTML / JS or insert HTML code directly into the page. This solution is licensed under the MIT license (free to download and use).

You can find more information in the GitHub repo here: https://github.com/SPJS/ModernCEWP

February 22, 2026

The webpart has been updated to make it compatible with the new CSP policy that Microsoft starts enforcing on March 1, 2026. It reads the HTML loaded with the Content link or inline in the HTML code section and extracts the script tags. It then loads the external scripts by creating script tags and adding them to the page DOM. Inline scripts will be executed using the function constructor to comply with the CSP rules.

I have also added a title property on the webpart that can be used to describe what the code does for easy maintenance on a page with multiple webparts.

You can find a complied version of the Modern CEWP here (v1.0.0.5): https://files.spjsworks.com/?dir=files%2FModernCEWP

This website uses cookies. By continuing to use this site, you accept our use of cookies.