JavaScript and CSS entered in code mode will run on that page when exiting code mode
See original GitHub issuesteps to reproduce
- Access to https://summernote.org/
- Turn on the code mode of Summernote
- Paste the following
<style>
ul, ol{
color: #668ad8;
border: dashed 2px #668ad8;
background: #f1f8ff;
padding: 0.5em 0.5em 0.5em 2em;
}
ul li, ol li {
line-height: 1.5;
padding: 0.5em 0;
}
</style>
- Exit code mode

They also apply to edit pages.
browser version and os version and summernote version
- MBP
- 10.12.6 (16G1036)
- Version 63.0.3239.108 (Official Build) (64-bit)
screenshot of issue
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Using code injection - Squarespace Help Center
To add JavaScript to a code injection field, surround the code with <script></script> tags. We recommend adding CSS to the Custom CSS Editor ......
Read more >Handling common HTML and CSS problems - MDN Web Docs
This includes linting code, handling CSS prefixes, using browser dev tools to track down problems, using polyfills to add support into browsers, ...
Read more >The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >Debugging in Visual Studio Code
VS Code has built-in debugging support for the Node.js runtime and can debug ... Many of the launch configuration attributes are supported in...
Read more >How to enter Full-Screen Mode with JavaScript - YouTube
In this video tutorial I'll be showing you how to use the JavaScript Fullscreen API which will allow your website to enter full-screen...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You are loading style sheet changes for the entire page (ul, ol) and summernote loads the style accordingly.
To avoid this, you need to use an event that parses the style selectors and forces them to be more specific. For example:
ul, ol {...}
becomes
.note-editing-area ul, .note-editing-area ol {...}
Your event will have to check if the parent class is already there so it does not add it a second time. That way you ensure that the applied styles affect the internal summernote structure only.
The second step, would be to make sure “.note-editing-area” is either renamed or used properly in your generated final html document, so that those style selectors work there as well.
You’re going to have the same issue with Javascript, as it affects the page as a whole. You’ll have the same with other editors as well. Keep in mind Summenote is meant to be a visual editor much like using Word, it’s not really intended to be used as a code editor. Codemirror is better suited to that.