question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript and CSS entered in code mode will run on that page when exiting code mode

See original GitHub issue

steps to reproduce

  1. Access to https://summernote.org/
  2. Turn on the code mode of Summernote
  3. 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>
  1. Exit code mode
summernote_-_super_simple_wysiwyg_editor

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

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, Jan 11, 2018

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.

1reaction
DiemenDesigncommented, Jan 12, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found