@activix/summernote 中文文档教程

发布于 3年前 浏览 11 项目主页 更新于 3年前

Summernote

超级简单的所见即所得编辑器。

构建状态npm 版本 依赖状态覆盖状态

Sauce Test Status

Summernote

Summernote 是一个 JavaScript 库,可帮助您在线创建所见即所得的编辑器。

主页:https://summernote.org

Why Summernote?

Summernote 有一些特殊功能:

  • Paste images from clipboard
  • Saves images directly in the content of the field using base64 encoding, so you don't need to implement image handling at all
  • Simple UI
  • Interactive WYSIWYG editing
  • Handy integration with server
  • Supports Bootstrap 3 and 4 integrities
  • Lots of plugins and connectors provided together

Installation and dependencies

Summernote 建立在 jQuery.

1. Include JS/CSS

在 HTML 的 标签中包含以下代码:

<!-- include libraries(jQuery, bootstrap) -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" />
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<!-- include summernote css/js-->
<link href="summernote.css" rel="stylesheet">
<script src="summernote.js"></script>

2. Target a element

然后将 div 标签放在 body 标签的某处。 此元素将替换为 summernote 编辑器。

<div id="summernote">Hello Summernote</div>

3. Summernote it!

最后,在 DOM 准备好后运行此脚本:

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

有关更多示例,请访问主页

API

code - 获取编辑器中文本的 HTML 源代码:

var html = $('#summernote').summernote('code');

有关 API 的更多详细信息,请参阅 文件

Warning - code injection

代码视图允许用户输入脚本内容。 确保过滤/清理服务器上的 HTML。 否则,攻击者可以将任意 JavaScript 代码注入客户端。

For contributing

https://github.com/summernote/summernote/blob/develop/CONTRIBUTING.md

Contacts

License

Summernote 可以在 MIT 许可下自由分发。

Summernote

Super simple WYSIWYG Editor.

Build Statusnpm versionDependency StatusCoverage Status

Sauce Test Status

Summernote

Summernote is a JavaScript library that helps you create WYSIWYG editors online.

Home page: https://summernote.org

Why Summernote?

Summernote has a few special features:

  • Paste images from clipboard
  • Saves images directly in the content of the field using base64 encoding, so you don't need to implement image handling at all
  • Simple UI
  • Interactive WYSIWYG editing
  • Handy integration with server
  • Supports Bootstrap 3 and 4 integrities
  • Lots of plugins and connectors provided together

Installation and dependencies

Summernote is built on jQuery.

1. Include JS/CSS

Include the following code in the <head> tag of your HTML:

<!-- include libraries(jQuery, bootstrap) -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" />
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>

<!-- include summernote css/js-->
<link href="summernote.css" rel="stylesheet">
<script src="summernote.js"></script>

2. Target a element

Then place a div tag somewhere in the body tag. This element will be replaced with the summernote editor.

<div id="summernote">Hello Summernote</div>

3. Summernote it!

Finally, run this script after the DOM is ready:

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

For more examples, please visit to homepage.

API

code - get the HTML source code underlying the text in the editor:

var html = $('#summernote').summernote('code');

For more detail about API, please refer to document.

Warning - code injection

The code view allows the user to enter script contents. Make sure to filter/sanitize the HTML on the server. Otherwise, an attacker can inject arbitrary JavaScript code into clients.

For contributing

https://github.com/summernote/summernote/blob/develop/CONTRIBUTING.md

Contacts

License

Summernote may be freely distributed under the MIT license.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文