Summernote WYSIWYG

喜你入骨 提交于 2021-02-11 17:49:15

问题


I can't initialize the summernote WYSIWYG editor in my app and i dont know why is not working.

I started to import the JS and CSS files, opened a div tag with "summernote" as id and inserted the javascript code in the bottom. The source files all are correctly pointed.

I want to render the text editor shown in hackerwins.github.io/summernote. It doesn't show the editor. Just the plain text "use element" inside the <div id="summernote"></div>

<!DOCTYPE html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html> <!--<![endif]-->
    <head>
    <meta charset="utf-8">

    <title>Dashboard</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
    <script src="//code.jquery.com/jquery-1.9.1.min.js"></script>   
    <link rel="stylesheet" href="http://localhost/projecto/assets/css/bootstrap.css">
    <link rel="stylesheet" href="http://localhost/projecto/assets/css/animations.css">
    <link rel="stylesheet" href="http://localhost/projecto/assets/css/main.css">
    <link rel="stylesheet" href="http://localhost/projecto/assets/css/extras.css">

    <script src="http://localhost/projecto/assets/js/vendor/modernizr-2.6.2.min.js"></script>


    <link href="http://localhost/projecto/assets/css/summernote.css" rel="stylesheet">
    <script src="http://localhost/projecto/assets/js/summernote.min.js"></script>



    </head>
    <body><div id="top"></div>
    <!--[if lt IE 7]>
    <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
    <![endif]-->



    <section id="topline">
    <div class="container">
    <div class="row">
    <div class="col-sm-6">
    <p>ana.coelho@anacoelhoarq.com |  <a href="http://localhost/projecto/index.php/admin/login/logout">Logout</a> </p>
    </div>

    </div>
    </div>        
    </section>


    <section id="header">
    <div class="container"><div class="row">

    <img class="navbar-brand" src="http://localhost/projecto/assets/img/logotipo.jpg" alt="logo">

    <div class="col-sm-12 mainmenu_wrap"><div class="main-menu-icon visible-xs"><span></span><span></span><span></span></div>
    <ul id="mainmenu" class="nav menu sf-menu responsive-menu superfish">
    <li class="active">
    <a href="./">Dashboard</a>
    </li>
    <li class="dropdown">
    <a href="./about.html">Projectos</a>
    <ul class="nav dropdown-menu">
    <li class="dropdown">
    <a href="./blog.html">Inserir</a>

    </li>
    <li class="dropdown">
    <a href="./blog.html">Consultar</a>

    </li>

    </ul>
    </li>
    <li class="dropdown">
    <a href="./blog.html">Publicações</a>
    <ul class="nav dropdown-menu">
    <li class="">
    <a href="./blog.html">Inserir</a>
    </li>
    <li class="">
    <a href="./blog.html">Consultar</a>
    </li>

    </ul>
    </li>
    <li class="dropdown">
    <a href="./blog.html">Newsletter</a>
    <ul class="nav dropdown-menu">
    <li class="">
    <a href="./blog.html">Consultar inscriçóes</a>
    </li>

    </ul>
    </li>

    </ul>
    </div>

    </div></div>
    </section><div class="container">

    <div class="row">


    <div id="summernote" class="summernote col-sm-12"><h4>use element</h4></div>

    </div>
    </div>
    <footer id="footer" style="padding: 0px;" class="darkgrey_section">
    <div class="container">
    <div class="row">


    <div class="col-sm-8">

    <p style="color: #AAA;">© 2014 - anacoelhoarq.com Todos os direitos reservados</p>

    </div>
    <div class="col-sm-4">



    </div>

    </div>
    </div>
    </footer>

    <script>$(document).ready(function() {
    $('.summernote').summernote();
    });</script>


    </body>
    </html>

回答1:


Check the documentation. You need to include jQuery, bootstrap and fontawesome:

<script src="//code.jquery.com/jquery-1.9.1.min.js"></script> 
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css"> 
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script> 
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">

and you need to initialise Summernote, like so:

$(document).ready(function() {
  $('#summernote').summernote();
});


来源:https://stackoverflow.com/questions/24509266/summernote-wysiwyg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!