Icons not showing with summernote rails

14,022

Solution 1

I searched for hours and finally solved it. Actually, summernote doesn't save icons locally, instead it download it

I added this links in header

  <link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
  <link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.1/summernote.css" rel="stylesheet">

And it did the job I 'll welcome if someone can elaborate it further

Solution 2

It's Simple

Just Download summernote compile zip file click here.

Unzip the file. Copy font folder. Paste it you summernote.css root. Be sure your summernote.css file stay with font folder. Now Refresh your Browser using Ctrl + F5.

Folder Location demo:enter image description here

Demo Output:enter image description here

Solution 3

Import the font files, it will work. I tried import through CSS @font-face rule. You can import in javascript also.

@font-face {
font-family: summernote;
src : url('/fonts/summernote.ttf');
src : url('/fonts/summernote.eot'),
      url('/fonts/summernote.woff');
}

Solution 4

Though an answer is already accepted, still I would like to post a better answer for people seeking a solution to the problem in question.

Of course this will work:

<link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.1/summernote.css"> 

But I prefer to STORE ASSETS LOCALLY. It eliminates the need of CDN which affects the loading time of the page its embedded in.

By default "summernote" looks for font-awesome icons (and some other summernote fonts) in the directory /css/font/:

//=================== The style-sheets stacking 
<link type="text/css" rel="stylesheet" href="css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="css/summernote.css">

//=================== The font goes here 
 /css/font/

So what u need to do is:

  1. Download fontawesome,
  2. Take out the fonts folder from the downloaded archive and rename it to font
  3. Place the directory font inside the css directory of the project.

And this should work.

Considering your assets are available like this http://localhost:1337/css/font/summernote.ttf //summernote.ttf is just an example

I hope this will help.

Thanks

Solution 5

After unzipping the Summernote distribution download, you must copy the Font folder to the same place you put the summernote.css file.

In this example, Elmer is the root folder of the website, and both summernote.css and the Font folder are copied to the /assets/css folder.

enter image description here

Similarly, the summernote.js file is copied to the /assets/js folder. If you're not using plugins or languages, that's all you need to install.

Here's the code to put in the header to load those files as shown:

<!-- include summernote css/js-->
<link rel="stylesheet" type="text/css"  charset="utf-8" href="/assets/css/summernote.css">
<script type="text/javascript" charset="utf-8" src="/assets/js/summernote.js"></script>

Note: Including the charset="utf-8" attribute is important.

Share:
14,022
Muhammad Faisal Iqbal
Author by

Muhammad Faisal Iqbal

Updated on June 13, 2022

Comments

  • Muhammad Faisal Iqbal
    Muhammad Faisal Iqbal almost 2 years

    enter image description here

    I followed Summernote-rails official to add rich text editor in my Rails project.

    Then in my edit.html.erb I added class place_editor to my text_area:

    <%= f.text_area :text, class: "place_editor form-control col-md-7 col-xs-12", rows: "15j ,placeholder: "Text", required: "required"%>
    

    and then JavaScript as:

    <script type="text/javascript">
     $(function() {
          $('.place_editor').summernote();
          var edit = function () {
            $('.click2edit').summernote({ focus: true });
          };
          $("#edit").click(function () {
            $('.click2edit').summernote({ focus: true });
          });
          $("#save").click(function () {
            var aHTML = $('.click2edit').code(); //save HTML If you need(aHTML: array).
            $('.click2edit').destroy();
          });
          // Adding Css to give border to text editor
          $(".note-editor").css("border", "solid 1px #e7eaec");
    
        });
    </script>
    

    Everything works fine except ICONS.